package cn.ryh.designpatterndemo.mediatorpattern;

/**
 * @ClassName ConcreteMediator
 * @Description TODO
 * @Author RaoYH
 * @Date 2019/4/23
 */
public class ConcreteMediator extends AbstractMediator {
    @Override
    public void doSomething(Class c) {
        //one进来要通知Two运行其自身的方法，来协助完成任务
        if (c.equals(super.colleagueOne.getClass())){
           this.colleagueOneDoSomething();
        }
        //Two进来要通知one运行其自身的方法,来协助完成任务
        if (c.equals(super.colleagueTwo.getClass())){
            this.colleagueTwoDoSomething();
        }

    }
    private void colleagueOneDoSomething(){
        colleagueTwo.selfMethod();
    }
    private void colleagueTwoDoSomething(){
        colleagueOne.selfMethod();
    }
}
